/*
    RoleCall provides a web service that web applications can use to find 
    the roles associated with a user that has been authenticated via OpenID. 
    Also provides a web-based user interface to manage the user roles 
    associated with partner web applications.
    
    Development of this software was supported in part by the David and Lucile 
    Packard Foundation and by the the Office Of Naval Research (ONR) 
     
    Copyright (c) 2012, 
    Monterey Bay Aquarium Research Institute - MBARI ( www.mbari.org )
    Michael Godin ( mikegodin AT users DOT sourceforge DOT net )

    RoleCall is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    RoleCall is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar (see the file COPYING.GPL).  If not, see 
    <http://www.gnu.org/licenses/>.  
*/

package org.mbari.rolecall.model;

import java.io.Serializable;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
 * Relay corresponds to the concept of OpenID Relaying Party -- i.e., a website
 * that would be requesting user credentials from this site.
 * 
 * @author godin
 * 
 */
@SuppressWarnings("serial")
@DatabaseTable(tableName = Relay.TABLE_NAME)
public class Relay implements Serializable {

    public static final String FIELD_NAME_ADMIN_ROLE_ASSIGNED = "adminRoleAssigned";

    public static final String FIELD_NAME_ADMIN_ROLE_NAME = "adminRoleName";

    public static final String FIELD_NAME_IP_ADDRESS = "ip_address";

    public static final String FIELD_NAME_NAME = "name";

    public static final String FIELD_NAME_PUBLIC_KEY = "publicKey";

    public static final String FIELD_NAME_ROLE_NAMES = "roleNames";

    public static final String TABLE_NAME = "Relay";

    @DatabaseField(columnName = FIELD_NAME_ADMIN_ROLE_ASSIGNED)
    protected boolean adminRoleAssigned;

    @DatabaseField(columnName = FIELD_NAME_ADMIN_ROLE_NAME)
    protected String adminRoleName;

    @DatabaseField(generatedId = true)
    protected int id;

    @DatabaseField(columnName = FIELD_NAME_IP_ADDRESS)
    protected String ipAddress;

    @DatabaseField(columnName = FIELD_NAME_NAME)
    protected String name;

    @DatabaseField(columnName = FIELD_NAME_PUBLIC_KEY, dataType = DataType.LONG_STRING)
    protected String publicKey;

    @DatabaseField(columnName = FIELD_NAME_ROLE_NAMES)
    protected String roleNames;

    // No-arg constructor with at least package visibility for persistence
    Relay() {
    }

    public Relay(String name, String adminRoleName, String roleNames,
            String publicKey, String ipAddress) {
        super();
        this.name = name;
        this.adminRoleName = adminRoleName;
        this.roleNames = roleNames;
        this.publicKey = publicKey;
        this.ipAddress = ipAddress;
    }

    /**
     * @return the adminRoleName
     */
    public String getAdminRoleName() {
        return adminRoleName;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @return the ipAddress
     */
    public String getIpAddress() {
        return ipAddress;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the publicKey
     */
    public String getPublicKey() {
        return publicKey;
    }

    /**
     * @return the roleNames
     */
    public String getRoleNames() {
        return roleNames;
    }

    /**
     * @return the adminRoleAssigned
     */
    public boolean isAdminRoleAssigned() {
        return adminRoleAssigned;
    }

    /**
     * @param adminRoleAssigned
     *            the adminRoleAssigned to set
     */
    public void setAdminRoleAssigned(boolean adminRoleAssigned) {
        this.adminRoleAssigned = adminRoleAssigned;
    }

    /**
     * @param adminRoleName
     *            the adminRoleName to set
     */
    public void setAdminRoleName(String adminRoleName) {
        this.adminRoleName = adminRoleName;
    }

    /**
     * @param ipAddress
     *            the ipAddress to set
     */
    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    /**
     * @param name
     *            the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param publicKey
     *            the publicKey to set
     */
    public void setPublicKey(String publicKey) {
        this.publicKey = publicKey;
    }

    /**
     * @param roleNames
     *            the roleNames to set
     */
    public void setRoleNames(String roleNames) {
        this.roleNames = roleNames;
    }

}
